package com.compmov.socialnetwork;

import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.Toast;

import com.compmov.datamodel.LugarAgregado;
import com.compmov.datamodel.Persona;
import com.compmov.libraries.LazyAdapter;
import com.compmov.libraries.LugaresAdapter;
import com.compmov.libraries.PersonaAdapter;
import com.compmov.webservice.LugarAgregadoWSClient;
import com.compmov.webservice.WSClientException;


public class PlacesAdded extends Activity {
	private ListView list;
	LugaresAdapter adapter;
	

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);	
		setContentView(R.layout.places_added);
		list = (ListView) findViewById(R.id.list);

		Persona per = com.compmov.libraries.Utils.getPersona();
		Bundle bundle = getIntent().getExtras();
		int idPer=com.compmov.libraries.Utils.getPersona().getId();
		if (bundle != null) {
			idPer=bundle.getInt("idPer");
		}
		
		LugarAgregadoWSClient lugarAgrWS = new LugarAgregadoWSClient("lugaragregado");
		
		try{
			List<LugarAgregado> lugaresAgr=lugarAgrWS.getLugarAgregado(idPer);
			
			adapter = new LugaresAdapter(this, lugaresAgr);
			list.setAdapter(adapter);
			
					
		} catch (WSClientException e) {
			Toast.makeText(getBaseContext(),"Error en el servidor. Intente de nuevo",
					Toast.LENGTH_SHORT).show();
		}
		
		

	}
	
	@Override
	public void onDestroy() {
		adapter.imageLoader.stopThread();
		list.setAdapter(null);
		super.onDestroy();
	}

		
}
